// import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'
const { JSEncrypt } = require('encryptlong')
// 密钥对生成 http://web.chacuo.net/netrsakeypair

const publicKey = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDs4qiYqUS9VJIpnq3oT+MnRLbBvol8B+P8mnjTqCqSCT1/OKCEI3fjWjkP7SC1T/qC4swDzppjvcWyCgQRF5i+bz76DpKBkOxv5k+ugxFSxLVTkSUZwNDv+7qmVTX72UEe1WbMR16lMCgEruIjv5ZxBZ0DabD25U+23SXHo9SXmQIDAQAB'

const privateKey = 'MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAMnTkxD2zOwFSZlUGMBTTvqkqm6OGxFAnT7wUWcAx28Cs6vyb+h0J/W6Zs11U+uc3ITXbO1/ZR3D1nJADwgrPTLws3EPXt4sjFUlKF22pAMlLXsxMx68fhKJqljbITRvLpKZ/lQ3OFgTV5IPrPIQ+zoJebMPfvMIRll8vHUDKg2fAgMBAAECgYAaII2VUJ3OoBCbDMv3edFrmQ2HKlZOsXKpxyqCjxNCR7NCuyvJh9/0a6ELT/kBM1lIySqMxEUuyT9lou1PPWm6h5v8s6eZXTmYX5S21OhKYJLES5tW7O7e1uSunHPlPFBUyg4vo1Pz/h1qOKGgSSL5TowO8JpalBjTNCneb942AQJBAOT4jof7hChx+NX8tmMppk9X3F5jEzpcbBYhWT8ZtO9jjNUQQ6bQ6AQK1+iSDDAi5D2y8ksLIY823IbpfB758N8CQQDhprgN1hq+2pV8CYtGeBdJjJJw0Szu8lfxzKofCAzzX89DNfMRcTwY6b6tckFnkO3UTgKl/16dh3uaTYXQX7tBAkB4m7iwRjsZ9tblGMWVvEWfO5+XlEZ3kmFY0t4oz8iv5Fc1j+iiwR3Fq1SJbAzBek+RdGYOQ2G9B1/oLKq1wmAvAkEArCKMQTHVEUaZxhdZwZYW3ap4g8tt5ZHFeNVR6X4wsu+honnjRKkG2VJmfNWuAx1R8CTabFsUiEM0DQ+aRszggQJBAJBG1Kn3kYS+8QhsDkPQzB1q06176NDpwnPfwJxWWe0J5nRxmxup64mSYDxuugXqyXFH/YSjL0JRJqZsfFnq3+I='

// 加密
export function encrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.encryptLong(txt) // 对数据进行加密
}

// 解密
export function decrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey(privateKey) // 设置私钥
  return encryptor.decryptLong(txt) // 对数据进行解密
}

